<script>
console.log('<?php echo $_SERVER['SERVER_ADDR']; ?>');
function isMobile() {
    return (/phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone|webOS|android/i.test(navigator.userAgent))
}
var _isMobile=isMobile();
_h=h= Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var sWidth = parseInt((window.innerWidth > 0) ? window.innerWidth : screen.width);
if(sWidth>750){sWidth=750;}
console.log(_isMobile);
//if(sWidth>540){sWidth=540;}
var _rate=(sWidth/750);
if(h<_rate*1246){
  h=_rate*1246;
}
function setKe(cname, cvalue){
  var cname='b1'+cname;
    var d = new Date();
    d.setTime(d.getTime() + (24*60*60*1000));
    var expires = "expires="+ d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getke(cname) {
  var cname='b1'+cname;
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(';');
    for(var i = 0; i <ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
         }
         if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
         }
     }
    return "";
}
function chinanum(num){
    var china = new Array('零','一','二','三','四','五','六','七','八','九');  
    var arr = new Array();
    var num=num+'';
    var english = num.split("")  
    for(var i=0;i<english.length;i++){
        arr[i] = china[english[i]];
    }
    if(2 == english.length){
        if('一' == arr[0]){
          return ('十'+arr[1]);
        }else{
          return (arr[0]+'十'+arr[1]);
        }
    }else{
      return arr.join("")  
    }
}
Array.prototype.shuffle = function(){
    let array = this;
    let len = array.length;
    for (let i = len - 1; i > 0; i--) {
      let j = Math.floor(Math.random() * (i + 1));
      [array[i], array[j]] = [array[j], array[i]];
    }
}
var _uid='<?php echo $uid ?>';
var _uPhone='';
var _uZu='';
var end;
_xiaoXue=['虹桥小学','龙柏一小','航华一小','航华二小','明强小学','平南小学','平阳小学','梅陇小学','罗阳小学','蔷薇小学','闵行实验小学','莘庄镇小','花园小学','新梅小学','申莘小学','田园小学','颛桥小学','北桥小学','曹行小学','景东小学','浦江一小','浦江二小','浦江三小','吴泾小学','闵行小学','华坪小学','鹤北小学','汽轮小学','江川小学','碧江小学','昆阳小学','七宝实小','黎明小学','交大附小','世博小学','莘松小学','上戏附小','华师附小','明强二小','鑫都小学','浦汇小学','文来外小','汇秀小学','田园二小','上师三小','永德实小','日新学校','七宝外小','诸翟学校','金汇实验','莘光学校','纪王学校','强恕学校','古美学校','康城学校','莘城学校','明星学校','文来实验','福山实验','君莲学校','华漕学校','世外浦江','复旦实验','复旦万科','燎原学校','协和尚音','协和双语','万源协和','星河湾校','博世凯','万科双语','民办美高','诺德安达','华二双语','德闳学校','弘梅小学','弘梅二小','华博小学','华虹小学','华星小学','马桥小学','双江小学','塘湾小学','文河小学','文汇学校','浦江文馨','银星学校','振兴小学','其他'];
_zhongXue=['航华中学','上虹中学','龙柏中学','七宝二中','梅陇中学','罗阳中学','莘松中学','七宝金都','北桥中学','友爱实验','浦江一中','浦江二中','浦江三中','闵行四中','闵行五中','颛桥中学','实验西校','鹤北中学','龙茗中学','七宝实验','基地附中','吴泾中学','七宝三中','华二初中','浦航实验','马桥万科','晶城中学','上师三附','田园初中','闵中实验','上师初中','上闵初中','七宝中学','华二紫竹','上师闵行分校','交附闵分','闵行中学','莘庄中学','上闵高中','华理科高','闵行三中','交大二附中','上宝中学','体育中学','七宝鑫都','浦江高中','金汇高中','北外高中','古美高中','文来中学','文绮中学','协和高中','闵教附中','协和教科','燎原高中','德怀特','诸翟学校','金汇实验','莘光学校','纪王学校','强恕学校','古美学校','康城学校','莘城学校','明星学校','文来实验','君莲学校','华漕学校','世外浦江','复旦闵行实验','交大马桥实验','七宝文来','复旦万科','燎原学校','协和尚音','协和双语','万源协和','星河湾校','博世凯','万科双语','民办美高','诺德安达','华二双语','德闳学校','其他'];
$(function(){
  $(".p1").show().addClass("fade-in");
  $('.container, .page').width(sWidth).height(h);
  $('.p-b').height(_rate*1206);

  $('.p1-t1').css({"top":_rate*72});

 
  $('.p1-jin').width(_rate*510).height(_rate*150).css({"top":_rate*520, "left":_rate*120});

  $('#p2-zu').width(_rate*346).height(_rate*78).css({"top":_rate*252, "left":_rate*290});
  $('#p2-school').width(_rate*346).height(_rate*78).css({"top":_rate*350, "left":_rate*290});
  $('#p2-name').width(_rate*346).height(_rate*78).css({"top":_rate*446, "left":_rate*288}); 
  $('#p2-idcard').width(_rate*346).height(_rate*78).css({"top":_rate*546, "left":_rate*288}); 
  $('#p2-phone').width(_rate*346).height(_rate*78).css({"top":_rate*644, "left":_rate*288});
   
  $('#p2-school2').width(_rate*346).height(_rate*78).css({"top":_rate*442, "left":_rate*288}); 

  

  $('.p2-next').width(_rate*346).height(_rate*90).css({"top":_rate*860, "left":_rate*200});

  $('.zige-next').width(_rate*346).height(_rate*120).css({"top":_rate*730, "left":_rate*200});

   
  
  
  $('.p3-next').width(_rate*346).height(_rate*140).css({"top":_rate*836, "left":_rate*200}); 

  $('.dx-abcd').css({"top":_rate*406});
  $('.dx-li').height(_rate*60).css({"line-height":_rate*60+'px','margin-bottom':_rate*6});
  $('.dx-li-ico').width(_rate*51).height(_rate*46).css({"top":_rate*6, "left":0});
  $('.dx-li span, .pduan-li span').css({"margin-left":_rate*66});
  $('.dx-dan').css({'margin-top':_rate*16});
  $('.dx-a, .dx-b, .dx-c, .dx-d, .pan-a, .pan-b').width(_rate*106);
  $('.dx-b').css({"left":_rate*118});
  $('.dx-c').css({"left":_rate*235});
  $('.dx-d').css({"left":_rate*352});

  
   
  $('.dx-up, .pan-up, .tian-up').width(_rate*325).css({"top":_rate*920, "left":_rate*60});
  $('.dx-next, .pan-next, .tian-next').width(_rate*325).css({"top":_rate*920, "left":_rate*380});
  $('.xze-title, .tian-title').height(_rate*68).css({"top":_rate*136,'line-height':_rate*72+'px'});

  $('.pan-abcd').css({"top":_rate*452});
  $('.pan-dan').css({'margin-top':_rate*16});
  $('.pan-a').css({"left":_rate*103});
  $('.pan-b').css({"left":_rate*248});

  $(".tktxt").width(_rate*120);
  
  
  $('.time-t1, .time-t2').height(_rate*35).css({"top":_rate*80, "left":_rate*84});
  $('.time-t2').width(_rate*586);

  $('.time-t3').width(_rate*200).height(_rate*50).css({"top":_rate*80, "right":_rate*100,'line-height':_rate*37+'px'});

   if (_isMobile || sWidth < 600) {
        $('.dx-abcd').css({"top":_rate*506});
        $('.pan-abcd').css({"top":_rate*552});
 
   }

   
   var _shuffle14Cookie=getke('sz_shuffle14Cookie');
   var _shuffle8Cookie=getke('sz_shuffle8Cookie');
   var _shuffle20Cookie=getke('sz_shuffle20Cookie');
   
   var _shuffle15Cookie=getke('sz_shuffle15Cookie');
   var _shuffle30Cookie=getke('sz_shuffle30Cookie');

   var _userCurStepCookie=getke('sz_userCurStepA'); //当前步骤
   var _userIdCookie=getke('sz_userId');
   var _userZuCookie=getke('sz_uZu');
   var _userPhoneCookie=getke('sz_phone');
   var _userCountEndTime=getke('sz_endTime');
    
    if ('' != _userIdCookie) {
      _uid=_userIdCookie;
    }
    if ('' != _userPhoneCookie) {
      _uPhone=_userPhoneCookie;
    }
    if ('' != _userZuCookie) {
      _uZu=_userZuCookie;
    }




   if('' == _shuffle15Cookie){
      var _shuffle15=[];
      for(var i=1;i<=15;i++){
        _shuffle15.push(i);
      }
      _shuffle15.shuffle();
      setKe('sz_shuffle15Cookie', _shuffle15);
   }else{
     var _shuffle15=_shuffle15Cookie.split(",");
   }

   if('' == _shuffle30Cookie){
      var _shuffle30=[];
      for(var i=1;i<=30;i++){
        _shuffle30.push(i);
      }
      _shuffle30.shuffle();
      setKe('sz_shuffle30Cookie', _shuffle30);
   }else{
     var _shuffle30=_shuffle30Cookie.split(",");
   }

   if('' == _shuffle20Cookie){
      var _shuffle20=[];
      for(var i=1;i<=20;i++){
        _shuffle20.push(i);
      }
      _shuffle20.shuffle();
      setKe('sz_shuffle20Cookie', _shuffle20);
   }else{
     var _shuffle20=_shuffle20Cookie.split(",");
   }

   if('' == _shuffle14Cookie){
      var _shuffle14=[];
      for(var i=1;i<=14;i++){
        _shuffle14.push(i);
      }
      _shuffle14.shuffle();
      setKe('sz_shuffle14Cookie', _shuffle14);
   }else{
     var _shuffle14=_shuffle14Cookie.split(",");
   }
   if('' == _shuffle8Cookie){
      var _shuffle8=[];
      for(var i=1;i<=8;i++){
        _shuffle8.push(i);
      }
      _shuffle8.shuffle();
      setKe('sz_shuffle8Cookie', _shuffle8);
   }else{
     var _shuffle8=_shuffle8Cookie.split(",");
   }
console.log(_shuffle8);
  console.log(_shuffle20);
  console.log(_shuffle14);
var _curId=0; //答题题目id
var _showId=_shuffle20[0];
$(".xze-t"+_showId+", .dx-t"+_showId).show();
var _dxData={}; 
var _panData={};
var _tianData={};
function _restartTime(){
  	var endDate = new Date();
            var min=endDate.getMinutes();
        endDate.setMinutes(min+20);
        end = endDate.getTime();
        if (typeof(_userCountEndTime) != "undefined" && '' != _userCountEndTime) {
            var date = new Date();  
            var now = date.getTime();
            if ((_userCountEndTime-now) >= 92000){
                end=_userCountEndTime;
            }
        }
        countTime(); 
        setKe('sz_endTime', end);
  }
if('' != _shuffle20Cookie){
    if('dxtm' == _userCurStepCookie && '' != _userPhoneCookie && '' != _userIdCookie){
        var _tmDataStoreCookie=getke('sz_tmData');
        var _tmKeyStoreCookie=getke('sz_tmKey');
        if("" != _tmDataStoreCookie){
          var _tmpTmData=_tmDataStoreCookie.split(",");
          var _tmpTmKey=_tmKeyStoreCookie.split(",");
          for(var _i=0;_i<_tmpTmData.length;_i++){
             _dxData[_tmpTmKey[_i]]=_tmpTmData[_i];
             _curId++;
          }
        }
        $(".xze-bt, .dx-abcd").hide();
        if(0 == _curId){
          _showId=_shuffle20[0];
        }else{
          _showId=_shuffle20[_curId-1];
        }
        
        $(".xze-t"+_showId+", .dx-t"+_showId).show();
        $(".xze-title").html("选择题（ "+(_curId+1)+" / 20 ）");
        
        for(var _i=0;_i<_curId;_i++){
          _showId=_shuffle20[_i];
          $(".dx-t"+_showId+" .dx-"+_dxData[_showId]+"1").attr("src","<?php echo $url; ?>/img/b-r.png");
          $(".dx-t"+_showId+" .dx-"+_dxData[_showId]+"2").attr("src","<?php echo $url; ?>/img/b-"+_dxData[_showId]+"1.png");
        }
        console.log('_dxData:'+_dxData);
        if ('zhong' == _uZu) {
          $(".p1").hide();
          $(".xze-zhong").show();
        }else{
          $(".p1").hide();
          $(".xze").show();
        }
        _restartTime();
        
   }
   
   if('pan' == _userCurStepCookie && '' != _userPhoneCookie && '' != _userIdCookie){
        var _tmDataStoreCookie=getke('sz_tmData');
        var _tmKeyStoreCookie=getke('sz_tmKey');
        if("" != _tmDataStoreCookie){
          var _tmpTmData=_tmDataStoreCookie.split(",");
          var _tmpTmKey=_tmKeyStoreCookie.split(",");
          for(var _i=0;_i<_tmpTmData.length;_i++){
             _panData[_tmpTmKey[_i]]=_tmpTmData[_i];
             _curId++;
          }
        }
       if ('zhong' == _uZu) {
         _showId=_shuffle30[_curId];
         $(".xze-title").html("判断题（ "+(_curId+1)+" / 30 ）");
         $(".pan-bt, .pan-abcd").hide();
         $(".pan-zhong .pan-t"+_showId+", .pan-zhong .pan-t"+_showId).show();
         for(var _i=0;_i<_curId;_i++){
            _showId=_shuffle30[_i];
            $(".pan-zhong .pan-t"+_showId+" .pan-"+_panData[_showId]+"1").attr("src","<?php echo $url; ?>/img/b-r.png");
            $(".pan-zhong .pan-t"+_showId+" .pan-"+_panData[_showId]+"2").attr("src","<?php echo $url; ?>/img/b-"+_panData[_showId]+"1.png");
          }
          $(".p1").hide();
          $(".pan-zhong").show(); 
       }else{
        _showId=_shuffle14[_curId];
       $(".xze-title").html("判断题（ "+(_curId+1)+" / 14 ）");
       $(".pan-bt, .pan-abcd").hide();
       $(".pan-t"+_showId+", .pan-t"+_showId).show();
       for(var _i=0;_i<_curId;_i++){
          _showId=_shuffle14[_i];
          $(".pan-t"+_showId+" .pan-"+_panData[_showId]+"1").attr("src","<?php echo $url; ?>/img/b-r.png");
          $(".pan-t"+_showId+" .pan-"+_panData[_showId]+"2").attr("src","<?php echo $url; ?>/img/b-"+_panData[_showId]+"1.png");
        }
        $(".p1").hide();
        $(".pan").show();
       }
        console.log('_panData:'+_panData);  
        _restartTime();
   }

   if('tian' == _userCurStepCookie && '' != _userPhoneCookie && '' != _userIdCookie){
        var _tmDataStoreCookie=getke('sz_tmData');
        var _tmData2StoreCookie=getke('sz_tmData2');
        var _tmKeyStoreCookie=getke('sz_tmKey');

        if("" != _tmDataStoreCookie){
          var _tmpTmData=_tmDataStoreCookie.split(",");
          var _tmpTmData2=_tmData2StoreCookie.split(",");
          var _tmpTmKey=_tmKeyStoreCookie.split(",");
          for(var _i=0;_i<_tmpTmData.length;_i++){
             _tianData[_tmpTmKey[_i]]={1:decodeURI(_tmpTmData[_i]),2:decodeURI(_tmpTmData2[_i])};
             _curId++;
          }
        }
        
       
       $(".tian-bt").hide();
       $(".p1").hide(); 
       console.log('_tianData:'+_tianData);
       
       if ('zhong' == _uZu) {
           _showId=_shuffle15[_curId];
           $(".tian-title").html("填空题（ "+(_curId+1)+" / 15 ）");
           $(".tian-t"+_showId).show();
           for(var _i=0;_i<_curId;_i++){
              _showId=_shuffle15[_i];
              if (typeof(_tianData[_showId]) != "undefined" && typeof(_tianData[_showId][1]) != "undefined" ) {
                   $(".tian-zhong .tian-t"+_showId+" .tk-1").val(_tianData[_showId][1]);
              }
              if (typeof(_tianData[_showId]) != "undefined"  && typeof(_tianData[_showId][2]) != "undefined" ) {
                   $(".tian-zhong .tian-t"+_showId+" .tk-2").val(_tianData[_showId][2]);
              }
 
            }

            if (_curId > 13){
              $(".tian-next").attr("src","<?php echo $url; ?>/img/dx-jiao.png");
            }
           
          $(".tian-zhong").show();
        }else{
            _showId=_shuffle8[_curId];
           $(".tian-title").html("填空题（ "+(_curId+1)+" / 8 ）");
           $(".tian-t"+_showId).show();
           for(var _i=0;_i<_curId;_i++){
              _showId=_shuffle8[_i];
              $(".tian .tian-t"+_showId+" .tk-1").val(_tianData[_showId][1]);
              $(".tian .tian-t"+_showId+" .tk-2").val(_tianData[_showId][2]);
            } 
          
            $(".tian").show();
            if (_curId > 6){
              $(".tian-next").attr("src","<?php echo $url; ?>/img/dx-jiao.png");
            }
        }
        _restartTime();

   }

   if('p3' == _userCurStepCookie && '' != _userPhoneCookie && '' != _userIdCookie){
        $(".p1").hide();
        $(".p3").show();
        
   }
   
   if('finish' == _userCurStepCookie && '' != _userPhoneCookie && '' != _userIdCookie){
        $(".p1").hide();
        $(".tipwc").show();
   }
  

}





   $(".dx-a").click(function(){
       _resetABCD('a');
   });
   $(".dx-b").click(function(){
       _resetABCD('b');
   });
   $(".dx-c").click(function(){
       _resetABCD('c');
   });
   $(".dx-d").click(function(){
       _resetABCD('d');
   });

   function _dxNext(){
       $(".xze-title").html("选择题（ "+(_curId+1)+" / 20 ）");
       $(".xze-bt, .dx-abcd").hide();
       _showId=_shuffle20[_curId];
       $(".xze-t"+_showId+", .dx-t"+_showId).show();
         
       if(_curId > 19){
          $(".xze").fadeOut();
          $(".pan").fadeIn();

          _curId=0;
          _showId=_shuffle14[_curId];
         $(".pan-t"+_showId+", .pan-t"+_showId).show();
         $(".xze-title").html("判断题（ 1 ）/ 14");
         setKe('sz_userCurStepA', 'pan');
         _userCurStepCookie='pan';
         setKe('sz_tmData', []);
         setKe('sz_tmKey', []);
          $.post("./api/?c=setdan", {tm:_dxData,op:_uid,ph:_uPhone,zu:_uZu}, function(data){}, "json");
        }
   }
   function _dxNextZhong(){
       $(".xze-zhong .xze-title").html("选择题（ "+(_curId+1)+" / 20 ）");
       $(".xze-bt, .dx-abcd").hide();
       _showId=_shuffle20[_curId];
       $(".xze-t"+_showId+", .dx-t"+_showId).show();
       
        if(_curId > 19){
          $(".xze-zhong").fadeOut();
          $(".pan-zhong").fadeIn();
          _curId=0;
          _showId=_shuffle30[_curId];
         $(".pan-t"+_showId+", .pan-t"+_showId).show();
         $(".xze-title").html("判断题（ 1 ）/ 30 ");
         setKe('sz_userCurStepA', 'pan');
         _userCurStepCookie='pan';
         setKe('sz_tmData', []);
         setKe('sz_tmKey', []);
          $.post("./api/?c=setdan", {tm:_dxData,op:_uid,ph:_uPhone,zu:_uZu}, function(data){}, "json");
        }
   }

   $(".dx-next").click(function(){
       _curId++;
       var _tmData=[];
       var _tmKey=[];  
       $.each(_dxData,function(key,value) {
            _tmKey.push(key);
            _tmData.push(value);
        }); 
        setKe('sz_tmData', _tmData);
        setKe('sz_tmKey', _tmKey);
        setKe('sz_userCurStepA', 'dxtm');
        _userCurStepCookie='dxtm';
        console.log(_uZu);
       if('zhong' == _uZu){
          _dxNextZhong();
       }else{
        _dxNext();
       }  

   });
   $(".dx-up").click(function(){
       if(0 == _curId){return;}
       if(_curId < 0){return;}
       _curId--;
       $(".xze-title").html("选择题（ "+(_curId+1)+" / 20 ）");
       $(".xze-bt, .dx-abcd").hide();
       _showId=_shuffle20[_curId];
       $(".xze-t"+_showId+", .dx-t"+_showId).show();
   });
   function _resetABCD(_type){
      _showId=_shuffle20[_curId];
      _dxData[_showId]=_type;
      console.log(_dxData);
      $(".dx-t"+_showId+" .dx-a1, .dx-t"+_showId+" .dx-b1, .dx-t"+_showId+" .dx-c1, .dx-t"+_showId+" .dx-d1").attr("src","<?php echo $url; ?>/img/b-h.png");
      $(".dx-t"+_showId+" .dx-a2").attr("src","<?php echo $url; ?>/img/b-a.png");
      $(".dx-t"+_showId+" .dx-b2").attr("src","<?php echo $url; ?>/img/b-b.png");
      $(".dx-t"+_showId+" .dx-c2").attr("src","<?php echo $url; ?>/img/b-c.png");
      $(".dx-t"+_showId+" .dx-d2").attr("src","<?php echo $url; ?>/img/b-d.png");
      $(".dx-t"+_showId+" .dx-"+_type+"1").attr("src","<?php echo $url; ?>/img/b-r.png");
      $(".dx-t"+_showId+" .dx-"+_type+"2").attr("src","<?php echo $url; ?>/img/b-"+_type+"1.png");
   }
   
   
   //_showId=_shuffle14[_curId];
   //$(".pan-t"+_showId+", .pan-t"+_showId).show();
   $(".pan-a").click(function(){
      if('zhong' == _uZu){
       _showId=_shuffle30[_curId];
      }else{
        _showId=_shuffle14[_curId];
      }
      _panData[_showId]='a';
      console.log(_showId);
      $(".pan-t"+_showId+" .pan-b1").attr("src","<?php echo $url; ?>/img/b-h.png");
      $(".pan-t"+_showId+" .pan-b2").attr("src","<?php echo $url; ?>/img/b-b.png");
       
      $(".pan-t"+_showId+" .pan-a1").attr("src","<?php echo $url; ?>/img/b-r.png");
      $(".pan-t"+_showId+" .pan-a2").attr("src","<?php echo $url; ?>/img/b-a1.png");
        
   });
   $(".pan-b").click(function(){
      if('zhong' == _uZu){
       _showId=_shuffle30[_curId];
      }else{
        _showId=_shuffle14[_curId];
      }
       _panData[_showId]='b';
      $(".pan-t"+_showId+" .pan-a1").attr("src","<?php echo $url; ?>/img/b-h.png");
      $(".pan-t"+_showId+" .pan-a2").attr("src","<?php echo $url; ?>/img/b-a.png");

      $(".pan-t"+_showId+" .pan-b1").attr("src","<?php echo $url; ?>/img/b-r.png");
      $(".pan-t"+_showId+" .pan-b2").attr("src","<?php echo $url; ?>/img/b-b1.png");
      
   });
   
   function _panNext(){
       _showId=_shuffle14[_curId];
       console.log(_panData);
       $(".xze-title").html("判断题（ "+(_curId+1)+" / 14 ）");
       $(".pan-bt, .pan-abcd").hide();
       
       $(".pan-t"+_showId+", .pan-t"+_showId).show();

        if(_curId > 13){
          $(".pan").hide();
          $(".tian").show();
          _curId=0;
         $(".tian-title").html("填空题（ 1 ）/ 8");
         $(".tian-bt").hide();
         _showId=_shuffle8[_curId];
         $(".tian-t"+_showId).show();
         setKe('sz_userCurStepA', 'tian');
         _userCurStepCookie='tian';
         setKe('sz_tmData', []);
         setKe('sz_tmKey', []);
          $.post("./api/?c=setpan", {tm:_panData,op:_uid,ph:_uPhone,zu:_uZu}, function(data){
         
          }, "json");
        }

   }

   function _panNextZhong(){
       _showId=_shuffle30[_curId];
       console.log(_panData);
       $(".xze-title").html("判断题（ "+(_curId+1)+" / 30 ）");
       $(".pan-bt, .pan-abcd").hide();
       
       $(".pan-zhong .pan-t"+_showId+", .pan-zhong .pan-t"+_showId).show();

       if(_curId > 29){
          $(".pan-zhong").hide();
          $(".tian-zhong").show();
          _curId=0;
         $(".tian-title").html("填空题（ 1 ）/ 15");
         $(".tian-bt").hide();
         _showId=_shuffle15[_curId];
         $(".tian-t"+_showId).show();
         setKe('sz_userCurStepA', 'tian');
         _userCurStepCookie='tian';
         setKe('sz_tmData', []);
         setKe('sz_tmKey', []);
          $.post("./api/?c=setpan", {tm:_panData,op:_uid,ph:_uPhone,zu:_uZu}, function(data){
         
          }, "json");
        }
   }
   $(".pan-next").click(function(){
       _curId++;

       var _tmData=[];
       var _tmKey=[];  
       $.each(_panData,function(key,value) {
            _tmKey.push(key);
            _tmData.push(value);
        }); 
        setKe('sz_tmData', _tmData);
        setKe('sz_tmKey', _tmKey);
        setKe('sz_userCurStepA', 'pan');
        _userCurStepCookie='pan';
       if('zhong' == _uZu){
          _panNextZhong()
       }else{
          _panNext();
       }  

    });

   $(".pan-up").click(function(){
       if(0 == _curId){return;}
       if(_curId < 0){return;}
       _curId--;
       
       $(".pan-bt, .pan-abcd").hide();
       
       if('zhong' == _uZu){
          $(".xze-title").html("判断题（ "+(_curId+1)+" / 30 ）");
           _showId=_shuffle30[_curId];
           $(".pan-zhong .pan-t"+_showId+", .pan-zhong .pan-t"+_showId).show();
       }else{
           $(".xze-title").html("判断题（ "+(_curId+1)+" / 14 ）");
           _showId=_shuffle14[_curId];
           $(".pan-t"+_showId+", .pan-t"+_showId).show();
       } 
       


   });
   

   
    function _tianNext(){
       showId=_shuffle8[_curId];
       var _txtA=$(".tian .tian-t"+_showId+' .tk-1').val();
       var _txtB=$(".tian .tian-t"+_showId+' .tk-2').val();
       if ('' != _txtA || '' != _txtB) {
          _tianData[_showId]={1:_txtA,2:_txtB};
       }
      console.log(_tianData);
      console.log('_curId:'+_curId);
       _curId++;
       _showId=_shuffle8[_curId];
       if(_curId > 0){
         $(".tian-tip").hide();
       }else{
         $(".tian-tip").show();
       }
       if (_curId > 6){
          $(".tian-next").attr("src","<?php echo $url; ?>/img/dx-jiao.png");
       }else{
          $(".tian-next").attr("src","<?php echo $url; ?>/img/dx-next.png");
       }

      $(".tian-title").html("填空题（ "+(_curId+1)+" / 8 ）");
      $(".tian-bt").hide();
       
      $(".tian-t"+_showId).show();
      
    }
    function _tianNextZhong(){
       showId=_shuffle15[_curId];
       var _txtA=$(".tian-zhong .tian-t"+_showId+' .tk-1').val();
       var _txtB=$(".tian-zhong .tian-t"+_showId+' .tk-2').val();
       if ('' != _txtA || '' != _txtB) {
          _tianData[_showId]={1:_txtA,2:_txtB};
       }
      console.log(_tianData);
       _curId++;
       if(_curId > 0){
         $(".tian-tip").hide();
       }else{
         $(".tian-tip").show();
       }
       _showId=_shuffle15[_curId];

       if (_curId > 13){
          $(".tian-next").attr("src","<?php echo $url; ?>/img/dx-jiao.png");
       }else{
          $(".tian-next").attr("src","<?php echo $url; ?>/img/dx-next.png");
       }

        console.log(_showId);
      
      $(".tian-title").html("填空题（ "+(_curId+1)+" / 15 ）");
      $(".tian-bt").hide();
       
      $(".tian-t"+_showId).show();
      
    }

   $(".tian-next").click(function(){
    console.log(_uZu);
       if('zhong' == _uZu){
          _tianNextZhong();
          if(_curId > 14){
            setKe('sz_userCurStepA', 'finish');
             _userCurStepCookie='finish';
            $(".tian").hide();
            $(".tipwc").show();
            $.post("./api/?c=settian", {tm:_tianData,op:_uid,ph:_uPhone,zu:_uZu}, function(data){
           
            }, "json");
            return;
          }
       }else{
          _tianNext();
          if(_curId > 7){
            setKe('sz_userCurStepA', 'finish');
             _userCurStepCookie='finish';
            $(".tian").hide();
            $(".tipwc").show();
            $.post("./api/?c=settian", {tm:_tianData,op:_uid,ph:_uPhone,zu:_uZu}, function(data){
           
            }, "json");
            return;
          }
       }

      var _tmData=[];
      var _tmData2=[];
      var _tmKey=[];
      $.each(_tianData,function(key,value) {
            _tmKey.push(key);
            _tmData.push(encodeURI(value[1]));
            _tmData2.push(encodeURI(value[2]));
        });  
        setKe('sz_tmData', _tmData);
        setKe('sz_tmData2', _tmData2);
        setKe('sz_tmKey', _tmKey);
        setKe('sz_userCurStepA', 'tian');
        _userCurStepCookie='tian';
 
    });
    
    $(".tian-up").click(function(){
       if(0 == _curId){return;}
       if(_curId < 0){return;}
       _curId--;
       if(_curId > 0){
         $(".tian-tip").hide();
       }else{
         $(".tian-tip").show();
       }
       $(".tian-bt").hide();
       if('zhong' == _uZu){
         _showId=_shuffle15[_curId];
         $(".tian-title").html("填空题（ "+(_curId+1)+" / 15 ）");
       }else{
         _showId=_shuffle8[_curId];
         $(".tian-title").html("填空题（ "+(_curId+1)+" / 8 ）");
       }
      $(".tian-next").attr("src","<?php echo $url; ?>/img/dx-next.png");
       $(".tian-t"+_showId).show();

   });


   $('.tktxt').bind('input propertychange', function() {
        var $this = $(this);
        var text_length = getByteLen($this.val());//获取当前文本框的长度
       // console.log(text_length);
        if(sWidth > 720){
          var current_width = parseInt(text_length/2) *18;
          current_width=current_width+18;
        }else{
          var current_width = parseInt(text_length/2) *12;
          current_width=current_width+12;
        }
        if(current_width > _rate*120){
          $this.css("width",current_width+"px");
        }
        //console.log(current_width)
    }); 
   function getByteLen(val) {
        var len = 0;
        for (var i = 0; i < val.length; i++) {
            var a = val.charAt(i);
            if (a.match(/[^\x00-\xff]/ig) != null) {//\x00-\xff→GBK双字节编码范围
                len += 2;
            }
            else {
                len += 1;
            }
        }
        return len;
    }

  $(".p1-jin").click(function(){
     _popMsg("考试已经结束");
     return; 
    $(".p1").hide();
    $(".zige").fadeIn();
  });
  $(".zige-next").click(function(){
    _popMsg("考试已经结束");
     return; 
    $(".zige").hide();
    $(".p2").fadeIn();
  });
  $(".p2-next").click(function(){
     var _zu=$("#p2-zu").val();
     var _school=$("#p2-school").val();
     var _school2=$("#p2-school2").val();
     var _name=$("#p2-name").val();
     var _idcard=$("#p2-idcard").val();
     var _phone=$("#p2-phone").val();
     if('' == _zu){
         _popMsg("请选择组别");
         return; 
     }
     if('' == _school){
         _popMsg("请选择学校");
         return; 
     }
     if('' == _school2 && '其他' == _school){
         _popMsg("请选择学校");
         return; 
     }
     if('' == _name){
         _popMsg("请输入学生姓名");
           return;  
    }
    if('' == _idcard){
         _popMsg("请输入身份证");
           return;  
    }
    if('' == _phone){
         _popMsg("请输入手机号");
           return;  
    }
    if(_phone.length < 10){
         _popMsg("请输入正确手机号");
         return;  
    }

    if('小学组' == _zu){
      _uZu='xiao';
    }else{
      _uZu='zhong';
    }
    
    _uPhone=_phone;
    $.post("./api/?c=setu", {uid:_uid,n:_name,idc:_idcard,ph:_phone,zu:_zu,school:_school,school2:_school2}, function(data){
          console.log(data);
          if('y' == data.s){
            $(".p2").fadeOut(400);
            $(".p3").fadeIn(600);
            setKe('sz_phone', _phone); 
            setKe('sz_userId', _uid);
            setKe('sz_uZu', _uZu);
            setKe('sz_userCurStepA', 'p3');
          }
    }, "json");


  });

  $('.p3-next').click(function(){
    $.post("./api/?c=gettime", {i:1}, function(data){
          if('n' == data.s){
             _popMsg("考试时间未到，10点正式考试");
             return;  
          }else{
            _restartTime();
            $(".p3").hide();
            if('zhong' == _uZu){
              $(".xze-zhong").fadeIn();
            }else{
              $(".xze").fadeIn();
            }
          }
    }, "json");
  });
 
  function _popMsg(msg){
    $(".weui-msg").html(msg);
        $(".js_dialog").show();
  }   
  $(".weui-btn").click(function(){
        $(".js_dialog").hide();
  });



  var _zongwidth=_rate*586;
  var _zongTime=60*20*1000;
  function countTime(){
    var date = new Date();  
    var now = date.getTime();
    var leftTime = end-now; 
    var m,s; 
    if (leftTime >= 0){
      m = Math.floor(leftTime/1000/60%60);
      s = Math.floor(leftTime/1000%60);
      var _tmpS=':'+s;
      if(s<10){
        _tmpS=':0'+s;
      }
      //console.log(leftTime);
      var _percent=1 - leftTime/_zongTime + 0.02;
      if(_percent>1){_percent=1;}
      
      $(".time-t1").width(_percent*_zongwidth);
      

      $(".time-t3").html(m + _tmpS );
      setTimeout(countTime,1000); 
    }else{
      $(".time-t3").html("00:00");
      _tmTMType='stop';
      _tmTimeId=0;
      $(".tipshijian").show();
      console.log('end');
    }
  }
  

    
  $(".tipshijian").click(function(){
    $(".tipshijian").hide();
    $(".tipwc").show();

    if('tian' == _userCurStepCookie){
      $.post("./api/?c=settian", {tm:_tianData,op:_uid,ph:_uPhone,zu:_uZu}, function(data){}, "json");
    }
    if('dxtm' == _userCurStepCookie){
      $.post("./api/?c=setdan", {tm:_dxData,op:_uid,ph:_uPhone,zu:_uZu}, function(data){}, "json");
    }
    if('pan' == _userCurStepCookie){
       $.post("./api/?c=setpan", {tm:_panData,op:_uid,ph:_uPhone,zu:_uZu}, function(data){}, "json");
    }
 
    setKe('sz_userCurStepA', 'finish');
  });


  $("#p2-zu").change(function(){
     var _val=$("#p2-zu").val();
     var _html='<option value="">请选择学校名称</option>';
     if('小学组' == _val){
        $.each(_xiaoXue, function( index, value ) {
           _html+='<option value="'+value+'">'+value+'</option>';
        });
        $("#p2-school").html(_html);
        return;
     }
     if('中学组' == _val){
        $.each(_zhongXue, function( index, value ) {
           _html+='<option value="'+value+'">'+value+'</option>';
        });
        $("#p2-school").html(_html);
     }
       
     console.log(_val);
     
   });


 
   $("#p2-school").change(function(){
       var _val=$("#p2-school").val();
       if('其他' == _val){
          $('#p2-name').css({"top":_rate*536}); 
          $('#p2-idcard').css({"top":_rate*630}); 
          $('#p2-phone').css({"top":_rate*726});
          $('#p2-school2').show();
          $(".p2-bg").attr("src","<?php echo $url; ?>/img/p2-2.png?v=2");
       }else{
          $('#p2-name').css({"top":_rate*446}); 
          $('#p2-idcard').css({"top":_rate*546}); 
          $('#p2-phone').css({"top":_rate*644});
          $('#p2-school2').hide();
          $(".p2-bg").attr("src","<?php echo $url; ?>/img/p2.png?v=3");
       }

    }); 
   
   
    
});
</script>